home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr52 / ncclib.zip / NCCDEMO.ZIP / G_DOS.PRG < prev    next >
Text File  |  1992-10-21  |  2KB  |  101 lines

  1. //═══════════════════════════════════════════════════════╕
  2. //  Program .....: G_Dos                                 │
  3. //  CopyRight ...: 1992 National Computer Consultants    │
  4. //                 All rights are reserved.              │
  5. //  Author ......: Greg Rice                             │
  6. //═══════════════════════════════════════════════════════╛
  7.  
  8. #include "fileio.ch"
  9.  
  10. #define CRLF    chr(13)+chr(10)
  11.  
  12.  
  13. STATIC dos_param_list_  :=  { ;
  14.                               "" , ;     // File
  15.                               "" , ;     // Index
  16.                               "" , ;     // Mode
  17.                               "" , ;     // View
  18.                               ""   ;     // .INI File
  19.                             }
  20.  
  21.  
  22. FUNCTION ParamPlace(x)
  23.  
  24.     IF x == Nil
  25.       Return( NIL )
  26.  
  27.     END
  28.  
  29.     IF ! subs(x,1,1) $ '/@'
  30.       IF empty(DosParamList(1))
  31.         DosParamList(1,x)
  32.  
  33.       ELSE
  34.         DosParamList(2,x)
  35.  
  36.       END
  37.  
  38.     ELSEIF subs(x,1,1) = '/'
  39.       DosParamList(3,DosParamList(3)+x)
  40.  
  41.     ELSEIF ".INI" $ uppe(x)
  42.       DosParamList(5,x)
  43.     ELSE
  44.       DosParamList(4,x)
  45.  
  46.     END
  47.  
  48. Return( NIL )
  49.  
  50.  
  51. FUNCTION DosParamList(x,y)
  52.  
  53.     IF y == NIL
  54.       IF x == NIL
  55.         Return( dos_param_list_ )
  56.       END
  57.       IF x > 0 .and. x < 6
  58.         Return( dos_param_list_[x] )
  59.  
  60.       END
  61.  
  62.     ELSE
  63.        dos_param_list_[x] := y
  64.  
  65.     END
  66.  
  67. Return( NIL )
  68.  
  69.  
  70. Function config()
  71.  
  72.     LOCAL handle, buffer := space(1024), i, knownId, x, z, csearch, tmp
  73.  
  74.     handle := fopen( subs(DosParamList(5),2), FO_READ+FO_SHARED )
  75.     if handle = -1
  76.       Return( .f. )
  77.     endif
  78.  
  79.     fread( handle, @buffer, 1024 )
  80.     buffer := subs(buffer,1,len(trim(buffer)))
  81.     x := StrToArray(buffer, CRLF, .f.)
  82.  
  83.     knownID := { ;
  84.                 { "FILE:"                 , { |x| DosParamList(1,x) } }, ;
  85.                 { "INDEX:"                , { |x| DosParamList(2,x) } }, ;
  86.                 { "MODE:"                 , { |x| DosParamList(3,DosParamList(3)+x) } }, ;
  87.                 { "VIEW:"                 , { |x| DosParamList(4,'@'+x) } }   ;
  88.                }
  89.  
  90.     FOR i = 1 to Len(x)
  91.        cSearch := x[i]
  92.        z := ascan( knownID, { |y| y[1]==subs(uppe(cSearch),1,at(":",cSearch)) } )
  93.        if z # 0
  94.          eval( knownID[z,2], subs(uppe(x[i]),at(":",x[i])+1) )
  95.        endif
  96.     NEXT
  97.  
  98.     fclose( handle )
  99.  
  100. Return( NIL )
  101.